﻿using System;
using System.Collections.Generic;

namespace LoungeRepo.Extensions
{
    internal static class IEnumerableExtensions
    {
        public static void ForEach<T>(this IEnumerable<T> source, Action<T> action)
        {
            foreach (T item in source)
                action(item);
        }


        public static IEnumerable<TDestination> Transform<TSource, TDestination>(this IEnumerable<TSource> source, Func<TSource, TDestination> transformation)
        {
            foreach(TSource element in source)
            {
                yield return transformation(element);
            }
        }

        public static void Transform<TSource>(this IEnumerable<TSource> source, Action<TSource> transformation)
        {
            foreach (TSource element in source)
                transformation(element);
        }
    }
}
